/*
 * EdgeCollection.h
 *
 *  Created on: 26/01/2012
 *      Author: paula
 */

#ifndef EDGECOLLECTION_H_
#define EDGECOLLECTION_H_

#include "PointTable.h"
#include "Edge.h"
#include <vector>

/*
 * Describes a data structure to represent layers of regions, based on collections of weighted edges
 */

class EdgeCollection {
private:
	typedef vector<Edge> cle;
	cle collection;

	PointTable t; //creates a PointTable to store points of this collection

	//Returns true if the Point p1 is to the right of Edge e1
	bool totherigth(Edge& e1, Point& p1);



public:
	EdgeCollection();
	virtual ~EdgeCollection();

	//Constructs a new EdgeCollection, initialized by an edge from x1,y1 to x2,y2 and weight w
	EdgeCollection(double x1, double y1, double x2, double y2, float w);
	//Constructs a new EdgeCollection, initialized by two points and weight w
	EdgeCollection(Point xy1, Point xy2, float w);
	//Constructs a new EdgeCollection based on other
	EdgeCollection(const EdgeCollection& base);

	//Constructs a new EdgeCollection based in a Polygon. Converts the representation of a circular list of vertices for Edge Collection representation.
	//EdgeCollection(Polygon); //class Polygon will be later created.

	//returns the size of collection
	unsigned size() {return collection.size();}
	vector<Edge>::iterator begin() {/*returns an iterator to beginning of collection*/ return collection.begin();}
	vector<Edge>::iterator end() {/*returns an iterator to the end of collection */ return collection.end();}
	Edge& operator [] (int i)  { return (collection[i]); }



	//prints all edges in the EdgeCollection
	void printcontent();

	//Sort the collection (Edges y minimal, x minimal)
	void sort();

	//Draws the geometry of the collection
	void draw(); //not implemented yet

	//Returns the field value in a point
	double valueat(Point& p);
	//Returns the field value in the coordinates determined by values of x,y
	double valueat(double x, double y);
	//Returns a list of fields values that match the list of points received as parameter
	vector<double> valueat(vector<Point> v);

	//Adds a new collection to a current collection processing their intersections
	EdgeCollection add(EdgeCollection& ec);//not implemented yet //JOSÉ: Seria o que você previu como Join ou seria melhor chamar de sun? ou isso já é o map overlay? fiquei confusa...

	//Adds an edge to collection
	void addedge(Edge& e);
	void addedge(double x1, double y1, double x2, double y2, float w);
	void addedge(Point xy1, Point xy2, float w);

	//scalar transformation - reports the edges where the scalar field changes, according a function received as parameter
	EdgeCollection checkfield(float(*f) (float)); //not implemented yet



};

#endif /* EDGECOLLECTION_H_ */
